package br.ufc.apsoo.utils;

import java.util.Date;

import org.joda.time.DateTime;

public class DateUtils {

	public static Date biggestBetween(Date date1, Date date2) {
		if (date1.after(date2)) {
			return date1;
		} else {
			return date2;
		}
	}

	public static Date lowestBetween(Date date1, Date date2) {
		if (date1.before(date2)) {
			return date1;
		} else {
			return date2;
		}
	}

	public static Integer numberOfDaysBetween(Date bigger, Date lower) {

		DateTime biggerDT = new DateTime(biggestBetween(bigger, lower));
		DateTime lowerDT = new DateTime(lowestBetween(bigger, lower));

		return biggerDT.getDayOfYear() - lowerDT.getDayOfYear();
	}
}
